//
//  AppViewViewController.m
//  Intake
//
//  Created by Mac Center on 26/09/2013.
//  Copyright (c) 2013 Mac Center. All rights reserved.
//

#import "AppViewViewController.h"
#import "PortraitViewController.h"
#import "LanscapeViewController.h"
#import "GuideToUseViewController.h"
@interface AppViewViewController ()
{
    PortraitViewController          *vcPortraint;
    GuideToUseViewController        *vcGuideToUse;
}
@end

@implementation AppViewViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    vcPortraint = [PortraitViewController new];
    self.deckView = [[IIViewDeckController alloc] initWithCenterViewController:vcPortraint];
    vcGuideToUse = [GuideToUseViewController new];
    self.deckView.leftController = vcGuideToUse;
    [self.navigationController pushViewController:self.deckView animated:YES];
    [self showSplashScreen];
    
}
                
- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void) showSplashScreen {
    [self.view addSubview:self.vSplashScreen];
    CGRect rect = self.vSplashScreen.frame;
    self.vSplashScreen.frame = CGRectMake(0, rect.size.height, rect.size.width, rect.size.height);

    [UIView animateWithDuration:1 animations:^{
        CGRect rect = self.vSplashScreen.frame;
        self.vSplashScreen.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
    } completion:^(BOOL finished) {
    }];

}

- (IBAction) closeSplashScreen:(id)sender {
    [UIView animateWithDuration:3 animations:^{
        CGRect rect = self.vSplashScreen.frame;
        self.vSplashScreen.frame = CGRectMake(0, rect.size.height, rect.size.width, rect.size.height);
    } completion:^(BOOL finished) {
        [self.vSplashScreen removeFromSuperview];
    }];

}

#pragma mark - orientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
	//	(iOS 5)
	//	Only allow rotation to portrait
	return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}

- (NSUInteger)supportedInterfaceOrientations
{
    //	(iOS 6)
    //	Only allow rotation to portrait
    return UIInterfaceOrientationMaskPortrait;
}

//- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
//{
//	//	(iOS 6)
//	//	Force to portrait
//	return UIInterfaceOrientationPortrait;
//}


-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        
        //        [self.navigationController pushViewController:landscape animated:NO];
        
    }
}

@end
